package sdau.hjk.service.Impl;

import sdau.hjk.dao.IUserReportDao;
import sdau.hjk.entity.UserReport;
import sdau.hjk.service.IUserReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 *@version 1.0
 *@author: huangjiakai
 *@create:2021−02-22 14:13
 *@className:com.hjk.service.Impl.UserReportService
 *@description: TODO
 */
@Service("userReportService")
public class UserReportService implements IUserReportService {
    @Autowired
    private IUserReportDao userReportDao;

    @Override
    public List<UserReport> findById(Integer id) {
        return userReportDao.findById(id);
    }

    @Override
    public void saveUserReport(UserReport userReport) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Calendar calendar = Calendar.getInstance();
        Date date =calendar.getTime();
        String dateStringParse = sdf.format(date);
        Date dateParse = sdf.parse(dateStringParse);
        userReport.setDate(dateParse);
        userReport.setApprove("未审核");
        userReportDao.saveUserReport(userReport);
    }
}
